<!DOCTYPE html>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script src='../../resources/gesture-util.js'></script>

<style>
  #overflow {
    width: 9999px;
    height: 9999px;
    float: left;
  }
</style>

<div id='overflow'></div>

<script>
  // Navigation steps:
  // 1- page gets first loaded and scrolled.
  // 2- loaded page away and then 'back'.
  // Test: ensure that by the time DOMContenLoaded fires (after a back navigation), scrollingElement.scrollTop/Left are set.

  let t = async_test('Test ensures that scrollingElement.scrollTop/Left properties are available by the time DOMContentLoaded event fires.');

  function init() {
    t.step(() => {
      if (window.name == 'second/load') {
        assert_equals(document.scrollingElement.scrollTop, 2000);
        assert_equals(document.scrollingElement.scrollLeft, 1000);
        window.name = '';

        t.done();
      } else {
        window.scrollTo(1000, 2000);

        window.name = 'second/load';
        setTimeout(() => { window.location = '../../resources/back.html'; }, 0);
      }
    });
  }

  window.addEventListener('DOMContentLoaded', init, true);
</script>